﻿using Microsoft.Practices.Unity.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Artech.Core
{
    /// <summary>
    /// This class is used to create <see cref="ApplicationContextScope"/> for cross-thread context propagation.
    /// </summary>
    public class DependentContext
    {
        /// <summary>
        /// Gets the <see cref="ContextItem"/> list.
        /// </summary>
        /// <value>
        /// The <see cref="ContextItem"/> list.
        /// </value>
        public ContextItemCollection Items { get; private set; }

        /// <summary>
        /// Gets the thread in which the <see cref="DependentContext"/> is created.
        /// </summary>
        /// <value>
        /// The thread.
        /// </value>
        public Thread Thread {get; private set;}

        /// <summary>
        /// Initializes a new instance of the <see cref="DependentContext"/> class.
        /// </summary>
        /// <param name="items">The <see cref="ContextItem"/> list.</param>
        public DependentContext(ContextItemCollection items)
        {
            Guard.ArgumentNotNull(items, "items");
            this.Items = items.Clone();
            this.Thread = Thread.CurrentThread;
        }
    }
}
